#include "StdAfx.h"
#include "PointInfoEx.h"




PointInfoEx::PointInfoEx(void)
{
}


PointInfoEx::~PointInfoEx(void)
{
	obstacles.clear();
}

void PointInfoEx::AddObstacle(const btRigidBody* obstacle)
{
	if(this->FindObstacle(obstacle) < 0)
		this->obstacles.push_back(obstacle);
}

void PointInfoEx::DeleteObstacle(const btRigidBody* obstacle)
{
	if(this->FindObstacle(obstacle) >= 0)
		this->obstacles.remove(obstacle);
}

const btRigidBody* PointInfoEx::GetObstacle(int index) const
{
	if(index < 0 || index >= this->obstacles.size())
		return nullptr;

	return this->obstacles.at(index);
}

void PointInfoEx::DeleteObstacle(int index)
{
	if(index < this->obstacles.size() && index >= 0)
	{
		this->obstacles.remove(this->GetObstacle(index));
	}
}

int PointInfoEx::FindObstacle(const btRigidBody* obstacle) const
{
	if(this->obstacles.size() == 0)
		return -1;

	return this->obstacles.findBinarySearch(obstacle);
}

const btAlignedObjectArray<const btRigidBody*> PointInfoEx::GetObstacles() const
{
	return this->obstacles;
}